﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XFPPT.NET.Enum;

namespace XFPPT.NET.Models
{
    /// <summary>
    /// 基于用户提示、文档等相关内容生成PPT，字数不得超过8000字，文件限制10M
    /// </summary>
    public class PPTCreateRequest
    {
        /// <summary>
        /// 无参构造函数，用于创建一个空的 CreateRequest 实例。
        /// </summary>
        public PPTCreateRequest() { }

        /// <summary>
        /// 带参构造函数，用于根据传入的参数创建 CreateRequest 实例。
        /// 会对传入的参数进行检查，不为空时才会赋值给对应的属性。
        /// </summary>
        /// <param name="query">用户生成PPT要求（最多8000字；query、file、fileUrl必填其一），不能为仅含空格的空字符串</param>
        /// <param name="file">上传文件 (file、fileUrl、query必填其一，如果传file或者fileUrl，fileName必填)</param>
        /// <param name="fileUrl">文件地址（file、fileUrl、query必填其一，如果传file或者fileUrl，fileName必填）</param>
        /// <param name="fileName">文件名(带文件名后缀；如果传file或者fileUrl，fileName必填)</param>
        /// <param name="templateId">直接供用户检索模板的ID,从PPT主题列表查询中获取</param>
        /// <param name="businessId">业务ID（非必传）- 业务方自行决定是否使用</param>
        /// <param name="author">PPT作者名：用户自行选择是否设置作者名</param>
        /// <param name="isCardNote">是否生成PPT演讲备注</param>
        /// <param name="search">是否联网搜索</param>
        /// <param name="language">语种</param>
        /// <param name="isFigure">是否自动配图</param>
        /// <param name="aiImage">ai配图类型： normal、advanced （isFigure为true的话生效）； normal-普通配图，20%正文配图；advanced-高级配图，50%正文配图</param>
        public PPTCreateRequest(string? query = "", byte[]? file = null, string? fileUrl = "", string? fileName = "",
                             string? templateId = "", string? businessId = "", string? author = "",
                             bool? isCardNote = null, bool? search = null, string? language = "",
                             bool? isFigure = null, string? aiImage = "")
        {
            // 若 query 不为空字符串且不只是空格，将其赋值给类的 query 属性
            if (!string.IsNullOrWhiteSpace(query))
            {
                this.query = query;
            }
            // 若 file 不为 null，将其赋值给类的 file 属性
            if (file != null)
            {
                this.file = file;
            }
            // 若 fileUrl 不为空字符串且不只是空格，将其赋值给类的 fileUrl 属性
            if (!string.IsNullOrWhiteSpace(fileUrl))
            {
                this.fileUrl = fileUrl;
            }
            // 若 fileName 不为空字符串且不只是空格，将其赋值给类的 fileName 属性
            if (!string.IsNullOrWhiteSpace(fileName))
            {
                this.fileName = fileName;
            }
            // 若 templateId 不为空字符串且不只是空格，将其赋值给类的 templateId 属性
            if (!string.IsNullOrWhiteSpace(templateId))
            {
                this.templateId = templateId;
            }
            // 若 businessId 不为空字符串且不只是空格，将其赋值给类的 businessId 属性
            if (!string.IsNullOrWhiteSpace(businessId))
            {
                this.businessId = businessId;
            }
            // 若 author 不为空字符串且不只是空格，将其赋值给类的 author 属性
            if (!string.IsNullOrWhiteSpace(author))
            {
                this.author = author;
            }
            // 若 isCardNote 有值，将其赋值给类的 isCardNote 属性
            if (isCardNote.HasValue)
            {
                this.isCardNote = isCardNote;
            }
            // 若 search 有值，将其赋值给类的 search 属性
            if (search.HasValue)
            {
                this.search = search;
            }
            // 若 language 不为空字符串且不只是空格，将其赋值给类的 language 属性
            if (!string.IsNullOrWhiteSpace(language))
            {
                this.language = language;
            }
            // 若 isFigure 有值，将其赋值给类的 isFigure 属性
            if (isFigure.HasValue)
            {
                this.isFigure = isFigure;
            }
            // 若 aiImage 不为空字符串且不只是空格，将其赋值给类的 aiImage 属性
            if (!string.IsNullOrWhiteSpace(aiImage))
            {
                this.aiImage = aiImage;
            }
        }


        /// <summary>
        /// 用户生成PPT要求（最多8000字；query、file、fileUrl必填其一）
        /// 注意：query不能为空字符串、仅包含空格的字符串
        /// User's requirements for generating a PPT (maximum 8000 characters; one of query, file, or fileUrl is required).
        /// Note: query cannot be an empty string or a string containing only spaces.
        /// </summary>
        public string? query { get; set; }

        /// <summary>
        /// 上传文件 (file、fileUrl、query必填其一，如果传file或者fileUrl，fileName必填)
        /// Uploaded file (one of file, fileUrl, or query is required. If file or fileUrl is provided, fileName is required).
        /// </summary>
        public byte[]? file { get; set; }

        /// <summary>
        /// 文件地址（file、fileUrl、query必填其一，如果传file或者fileUrl，fileName必填）
        /// File address (one of file, fileUrl, or query is required. If file or fileUrl is provided, fileName is required).
        /// </summary>
        public string? fileUrl { get; set; }

        /// <summary>
        /// 文件名(带文件名后缀；如果传file或者fileUrl，fileName必填)
        /// File name (with file extension; if file or fileUrl is provided, fileName is required).
        /// </summary>
        public string? fileName { get; set; }

        /// <summary>
        /// 直接供用户检索模板的ID,从PPT主题列表查询中获取
        /// ID for directly retrieving templates by the user, obtained from the PPT theme list query.
        /// </summary>
        public string? templateId { get; set; }

        /// <summary>
        /// 业务ID（非必传）- 业务方自行决定是否使用
        /// Business ID (not required) - The business party decides whether to use it.
        /// </summary>
        public string? businessId { get; set; }

        /// <summary>
        /// PPT作者名：用户自行选择是否设置作者名
        /// PPT author name: The user can choose whether to set the author name.
        /// </summary>
        public string? author { get; set; }

        /// <summary>
        /// 是否生成PPT演讲备注 默认false
        /// Whether to generate PPT speech notes.
        /// </summary>
        public bool? isCardNote { get; set; } 

        /// <summary>
        /// 是否联网搜索 默认false
        /// Whether to search online.
        /// </summary>
        public bool? search { get; set; }

        /// <summary>
        /// 语种 默认 cn
        /// Language.
        /// </summary>
        public string? language { get; set; }

        /// <summary>
        /// 是否自动配图 默认false
        /// Whether to automatically insert pictures.
        /// </summary>
        public bool? isFigure { get; set; }

        /// <summary>
        /// ai配图类型： normal、advanced （isFigure为true的话生效）； normal-普通配图，20%正文配图；advanced-高级配图，50%正文配图
        /// AI picture insertion type: normal, advanced (effective when isFigure is true); normal - ordinary picture insertion, 20% of the text with pictures; advanced - advanced picture insertion, 50% of the text with pictures.
        /// </summary>
        public string? aiImage { get; set; }
    }
}
